package com.ebank.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.ebank.model.User;
public class BalanceDao {
	public boolean edit(User user) {
		boolean result = false;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5",
					"root","root");
			PreparedStatement ps = null;
			try {
				ps = conn.prepareStatement("UPDATE account SET username = ? ,Balance = ? ");

				ps.setString(1, user.getUsername());
				ps.setDouble(2, user.getBalance());
				
				ps.execute();
				result = true;
			} finally {
				ps.close();
			}
			conn.close();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return result;
	}
}
